package com.MedDroid;

import android.app.Application;
import com.MedDroid.control.AuthenticationControl;
import com.MedDroid.control.DatabaseControl;
import com.MedDroid.control.InterfaceControl;
import com.MedDroid.control.ScheduleControl;

/**
 * Created with IntelliJ IDEA.
 * User: Romen
 * Date: 01/12/13
 * Time: 8:09 PM
 * Description: This class is instanciated when the application launches. Useful for storing globally accessible data. Should be data only though, minimal processing.
 */
public class MainApp extends Application
{
	static final boolean Debug = true;

	public AuthenticationControl AuthenticationC;
	public DatabaseControl DatabaseC;
	public InterfaceControl InterfaceC;
	public ScheduleControl ScheduleC;

	@Override
	public void onCreate()
	{
		AuthenticationC = new AuthenticationControl(this);
		DatabaseC = new DatabaseControl(this);
		InterfaceC = new InterfaceControl(this);
		ScheduleC = new ScheduleControl(this);

		DatabaseC.startup();
	}

	public void onStop()
	{
		DatabaseC.shutdown();
	}

	public static void log(String string)
	{
		if (Debug)
		{
			System.out.println(string);
		}
	}

	//Get Methods
	public AuthenticationControl getAuthentication()
	{
		return AuthenticationC;
	}

	public DatabaseControl getDatabase()
	{
		return DatabaseC;
	}

	public InterfaceControl getInterface()
	{
		return InterfaceC;
	}

	public ScheduleControl getSchedule()
	{
		return ScheduleC;
	}
}
